Skip to content

Conversation

@lingtonglu
Copy link
Contributor

No description provided.

@MengshiZhang MengshiZhang self-requested a review July 10, 2025 04:51
@wilsonccccc wilsonccccc requested a review from MengshiZhang July 11, 2025 05:13
try:
credentials = service_account.Credentials.from_service_account_info(self.cred_json, scopes=["https://www.googleapis.com/auth/cloud-platform"])

# refresh token - run in thread pool to avoid blocking
Copy link
Contributor

@Dokujaa Dokujaa Jul 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im wondering if we could optimize this logic. OAuth2 Token's generally last an hour, but we are refreshing the token every call. Instead could we store the token in Redis cache, and then check for cache miss/expiry and then refresh the token.

Implementation approach:

  1. Check Redis cache for existing valid token first
  2. If cache miss or expired, refresh token and cache it
  3. Use credentials.expiry to set proper TTL (with 5-10 min safety buffer)
  4. Cache key: f"vertex_token:{hash(service_account_json)}"

Could slightly help performance

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion 👍. I have some questions regarding to it. Let's move the discussion to your PR: #15

@lingtonglu lingtonglu requested a review from wilsonccccc July 22, 2025 00:38
@lingtonglu lingtonglu requested a review from wilsonccccc July 23, 2025 04:21
@wilsonccccc wilsonccccc merged commit 7409f06 into main Jul 23, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants